<template>
	<view class="page">
		<view class="top-view" :style="{paddingTop:navHeight + 'px',height:`calc(${navHeight}px + 230rpx)`}">
			<image class="banner" src="../../static/mine/banner.png"></image>
			<view class="top-content">
				<view class="user">
					<view class="user-msg">
						<image class="tx" :src="userInfo.avatar"></image>
						<view class="msg">
							<view class="name">
								{{userInfo.nickname}}
							</view>
							<view class="id">
								ID:{{userInfo.id}}
							</view>
						</view>
					</view>
					<view class="bianji flexAJC" @click="editUserInfo">
						<image class="bj" mode="widthFix" src="../../static/mine/bianji.png"></image>
						编辑
					</view>
				</view>
			</view>
		</view>
		<view class="main">
			<view class="card">
				<view class="title">
					我的邀请
				</view>
				<view class="yq">
					<view class="yq-item" @click="toMyInvite(1)">
						<image class="icon" src="../../static/mine/yaoqingzhong.png"></image>
						<view class="txt">
							邀请中
						</view>
					</view>
					<view class="yq-item" @click="toMyInvite(2)">
						<image class="icon" src="../../static/mine/yaoqing.png"></image>
						<view class="txt">
							被邀请
						</view>
					</view>
					<view class="yq-item" @click="toMyInvite(3)">
						<image class="icon" src="../../static/mine/tongyi.png"></image>
						<view class="txt">
							已同意
						</view>
					</view>
				</view>
			</view>
			<view class="card">
				<view class="title">
					设置
				</view>
				<u-cell-group>
					<u-cell title="版本信息" value="V1.0.0">
						<image slot="icon" class="cell-icon" src="../../static/mine/banben.png" mode="widthFix"></image>
					</u-cell>
					<u-cell title="意见建议" :isLink="true" @click="toFaceBack">
						<image slot="icon" class="cell-icon" src="../../static/mine/yijian.png" mode="widthFix"></image>
					</u-cell>
					<u-cell title="关于我们" :isLink="true" @click="toGYWM" :border="false">
						<image slot="icon" class="cell-icon" src="../../static/mine/guanyu.png" mode="widthFix"></image>
					</u-cell>
				</u-cell-group>
			</view>
		</view>

		<tabbar index="user"></tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				navHeight: 0,
				userInfo: {}
			};
		},
		onLoad() {
			// #ifdef MP-WEIXIN
			let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
			const custom = wx.getMenuButtonBoundingClientRect()

			let navigationBarHeight = custom.height + (custom.top - statusBarHeight) * 2
			this.navHeight = navigationBarHeight + statusBarHeight
			// #endif
		},
		onShow() {
			if (uni.getStorageSync('token')) {
				this.getUserInfo()
			}
		},
		methods: {
			toGYWM(){
				uni.navigateTo({
					url:"/pages/mine/aboutUs"
				})
			},
			toFaceBack(){
				uni.navigateTo({
					url:"/pages/mine/faceBack"
				})
			},
			toMyInvite(e) {
				uni.navigateTo({
					url: "/pages/mine/invite?type=" + e
				})
			},
			getUserInfo() {
				this.$api.user.userIndex().then(res => {
					{
						this.userInfo = res.data.user
					}
				})
			},
			editUserInfo() {
				uni.navigateTo({
					url: "/pages/mine/userInfo"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		position: relative;
		min-height: 100vh;
		width: 100%;
		background-color: #F7F7F7;

		.top-view {
			position: relative;
			width: 100%;
			height: auto;

			.banner {
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;
				z-index: 1;
			}

			.top-content {
				width: 100%;
				height: 100%;
				position: relative;
				z-index: 2;

				.user {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding-left: 32rpx;

					.user-msg {
						display: flex;

						.tx {
							width: 140rpx;
							height: 140rpx;
							flex-shrink: 0;
							margin-right: 42rpx;
							border-radius: 50%;
						}

						.msg {
							.name {
								margin-top: 26rpx;
								font-size: 28rpx;
								font-weight: bold;
								margin-bottom: 38rpx;
							}

							.id {
								color: #685D1F;
							}
						}
					}

					.bianji {
						width: 154rpx;
						height: 70rpx;
						background: rgba(255, 255, 255, 0.8);
						border-radius: 35rpx 0px 0px 35rpx;

						.bj {
							width: 22rpx;
							height: auto;
							margin-right: 10rpx;
						}
					}
				}
			}
		}

		.main {
			position: relative;
			width: 100%;
			top: -40rpx;
			padding: 0 32rpx;
			z-index: 2;

			.card {
				width: 100%;
				box-shadow: 0px 1px 4rpx 0px rgba(190, 190, 190, 0.35);
				background: #FFFFFF;
				border-radius: 14rpx;
				margin-bottom: 18rpx;
				padding: 40rpx;

				.title {
					color: #232323;
					font-weight: bold;
					font-size: 28rpx;
					margin-bottom: 40rpx;
				}

				.yq {
					width: 100%;
					display: flex;
					justify-content: space-around;

					.yq-item {
						.icon {
							width: 58rpx;
							height: 58rpx;
							display: block;
							margin: 0 auto 22rpx;
						}

						.txt {
							color: #454545;
							font-size: 28rpx;
							text-align: center;
						}
					}
				}

				.cell-icon {
					width: 36rpx;
					height: 36rpx;
					margin-right: 24rpx;
				}
			}
		}
	}
	::v-deep .u-cell__body{
		padding: 42rpx 10rpx !important;
	}
</style>